home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / fieldbdy.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  6.0 KB  |  168 lines

  1. //=============================================================================
  2. // File:       fieldbdy.h
  3. // Contents:   Declarations for DwFieldBody
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_FIELDBDY_H
  24. #define DW_FIELDBDY_H
  25.  
  26. #include <iostream>
  27.  
  28. #ifndef DW_CONFIG_H
  29. #include <mimelib/config.h>
  30. #endif
  31.  
  32. #ifndef DW_STRING_H
  33. #include <mimelib/string.h>
  34. #endif
  35.  
  36. #ifndef DW_MSGCMP_H
  37. #include <mimelib/msgcmp.h>
  38. #endif
  39.  
  40. //=============================================================================
  41. //+ Name DwFieldBody -- Class representing a MIME header field body
  42. //+ Description
  43. //. {\tt DwFieldBody} represents the field-body element in the BNF grammar
  44. //. specified by RFC-822.  It is an abstract base class that defines the
  45. //. interface common to all structured field bodies.
  46. //.
  47. //. In the tree (broken-down) representation of a message, a {\tt DwFieldBody}
  48. //. object may be either a leaf node, having a parent but no child nodes, or
  49. //. an intermediate node, having a parent and one or more child nodes.  The
  50. //. parent node is the {\tt DwField} object that contains it.  Child nodes,
  51. //. if present, depend on the particular subclass of {\tt DwFieldBody} that
  52. //. is instantiated.  A {\tt DwAddressList} object, for example, has
  53. //. {\tt DwAddress} objects as its child nodes.
  54. //.
  55. //. Since {\tt DwFieldBody} is an abstract base class, you cannot create
  56. //. instances of it directly.  Normally, objects of classes derived from
  57. //. {\tt DwFieldBody} are obtained by calling convenience member functions
  58. //. in the class {\tt DwHeaders}.
  59. //.
  60. //. Some MIME parsers are broken in that they do not handle the folding of
  61. //. some fields properly.  {\tt DwFieldBody} folds its string representation
  62. //. by default.  You can disable folding, however, by calling the
  63. //. {\tt SetFolding()} member function.  To determine if folding is enabled,
  64. //. call {\tt IsFolding()}.
  65. //=============================================================================
  66. // Last updated 1997-08-24
  67. //+ Noentry ~DwFieldBody mLineOffset mDoFolding _PrintDebugInfo
  68.  
  69.  
  70. class DW_EXPORT DwFieldBody : public DwMessageComponent {
  71.  
  72.     friend class DwField;
  73.  
  74. public:
  75.  
  76.     DwFieldBody();
  77.     DwFieldBody(const DwFieldBody& aFieldBody);
  78.     DwFieldBody(const DwString& aStr, DwMessageComponent* aParent=0);
  79.     //. The first constructor is the default constructor, which sets the
  80.     //. {\tt DwFieldBody} object's string representation to the empty
  81.     //. string and sets its parent to {\tt NULL}.
  82.     //.
  83.     //. The second constructor is the copy constructor, which performs a
  84.     //. deep copy of {\tt aFieldBody}.
  85.     //. The parent of the new {\tt DwFieldBody} object is set to {\tt NULL}.
  86.     //.
  87.     //. The third constructor copies {\tt aStr} to the {\tt DwFieldBody}
  88.     //. object's string representation and sets {\tt aParent} as its parent.
  89.     //. The virtual member function {\tt Parse()} should be called immediately
  90.     //. after this constructor in order to parse the string representation.
  91.     //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
  92.     //. a class derived from {\tt DwField}.
  93.  
  94.     virtual ~DwFieldBody();
  95.  
  96.     const DwFieldBody& operator = (const DwFieldBody& aFieldBody);
  97.     //. This is the assignment operator, which performs a deep copy of
  98.     //. {\tt aFieldBody}.  The parent node of the {\tt DwFieldBody} object
  99.     //. is not changed.
  100.  
  101.     void SetOffset(int aOffset);
  102.     //. Sets the offset to {\tt aOffset}.  The offset is used when folding
  103.     //. lines.  It indicates how much the first line should be offset to
  104.     //. account for the field name, colon, and initial white space.
  105.  
  106.     void SetFolding(DwBool aTrueOrFalse);
  107.     //. Enables ({\tt aTrueOrFalse = DwTrue}) or disables
  108.     //. ({\tt aTrueOrFalse = DwFalse}) the folding of fields.  The default
  109.     //. is to fold fields.  Unfortunately, some parsers are broke and
  110.     //. do not handle folded lines properly.  This function allows a kludge
  111.     //. to deal with these broken parsers.
  112.  
  113.     DwBool IsFolding() const;
  114.     //. Returns a boolean indicating if folding of fields is enabled.
  115.  
  116. protected:
  117.  
  118.     int mLineOffset;
  119.     DwBool mDoFolding;
  120.  
  121. private:
  122.  
  123.     static const char* const sClassName;
  124.  
  125. public:
  126.  
  127.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  128.     //. This virtual function, inherited from {\tt DwMessageComponent},
  129.     //. prints debugging information about this object to {\tt aStrm}.
  130.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  131.     //. components down to a level of {\tt aDepth}.
  132.     //.
  133.     //. This member function is available only in the debug version of
  134.     //. the library.
  135.  
  136.     virtual void CheckInvariants() const;
  137.     //. Aborts if one of the invariants of the object fails.  Use this
  138.     //. member function to track down bugs.
  139.     //.
  140.     //. This member function is available only in the debug version of
  141.     //. the library.
  142.  
  143. protected:
  144.  
  145.     void _PrintDebugInfo(std::ostream& aStrm) const;
  146.  
  147. };
  148.  
  149.  
  150. inline void DwFieldBody::SetOffset(int aOffset)
  151. {
  152.     mLineOffset = aOffset;
  153. }
  154.  
  155.  
  156. inline void DwFieldBody::SetFolding(DwBool aTrueOrFalse)
  157. {
  158.     mDoFolding = aTrueOrFalse;
  159. }
  160.  
  161.  
  162. inline DwBool DwFieldBody::IsFolding() const
  163. {
  164.     return mDoFolding;
  165. }
  166.  
  167. #endif
  168.